﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 习题2._1_与7无关的数_CSharp
{
    class Program
    {
        static void Main(string[] args)
        {
			string line;
            while ((line = Console.ReadLine()) != null)
            {
				string[] tokens = line.Split();
				int QuadraticSum = 0;
				int n = Convert.ToInt32(tokens[0]);
				double n2 = double.Parse(tokens[0]);
                if (n == n2)
                {
					Console.WriteLine("true");
                }
				for (int i = 1; i <= n; ++i)
				{
					if (i % 7 == 0 || i / 10 == 7 || i % 10 == 7)
					{
						continue;
					}
					QuadraticSum += i * i;
				}
				Console.WriteLine(QuadraticSum);
			}
		}
    }

	/*
	作者：管理员
链接：https://www.nowcoder.com/discuss/276
来源：牛客网

public class Program {
  public static void Main() {
    string line;
    while ((line = System.Console.ReadLine ()) != null) {// 注意，如果输入是多个测试用例，请通过while循环处理多个测试用例
      string[] tokens = line.Split();
      System.Console.WriteLine(int.Parse(tokens[0]) + int.Parse(tokens[1]));
    }
  }
}
	 
	 */
}
